package com.idc.config.security.plugins;

import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author Trump
 * @desc
 * @date 2019/3/27 19:43
 */
public class SimplePasswordEncoder implements PasswordEncoder {
	private final String prefix = "$${{";
	private final String subfix = "}}$$";

	/**
	 *
	 * @param rawPassword 浏览器传入的密码
	 * @return
	 */
	@Override
	public String encode(CharSequence rawPassword) {
		return prefix+rawPassword+subfix;
	}

	@Override
	public boolean matches(CharSequence rawPassword, String encodedPassword) {
		return encode(rawPassword).equals(encodedPassword);
	}
}
